/*
 * Copyright (C) Bosch Connected Devices and Solutions GmbH.
 * All Rights Reserved. Confidential.
 *
 * Distribution only to people who need to know this information in
 * order to do their job.(Need-to-know principle).
 * Distribution to persons outside the company, only if these persons
 * signed a non-disclosure agreement.
 * Electronic transmission, e.g. via electronic mail, must be made in
 * encrypted form.
 */
/*----------------------------------------------------------------------------*/

/**
 *  @file
 *
 *  @brief Configuration header for the AppController.c file.
 *
 */

/* header definition ******************************************************** */
#ifndef APPCONTROLLER_H_
#define APPCONTROLLER_H_
#define FAT_FILE_SYSTEM             1 /** Macro to write data into SDCard either through FAT file system or SingleBlockWriteRead depends on the value **/
#define WRITEREAD_DELAY             UINT32_C(2000)   /**< Millisecond delay for WriteRead timer task */
#define DATA_TO_WRITE_IN_SDCARD     "This content is created by SD card Read/Write functionality using FAT32 file system\n"
/* local interface declaration ********************************************** */
#include "XDK_Utils.h"


/* local type and macro definitions */

/* local module global variable declarations */

/* local inline function definitions */

/* local type and macro definitions */

/* WLAN configurations ****************************************************** */

/**
 * WLAN_SSID is the WIFI network name where user wants connect the XDK device.
 * Make sure to update the WLAN_PSK constant according to your required WIFI network.
 */
//#define WLAN_SSID_DEFAULT                           "TP-LINK_2BCD24"
#define ALT_WLAN_SSID_DEFAULT                           "TP-LINK_2"


//#define WLAN_SSID_DEFAULT                     "fitlet2-001"

/**
 * WLAN_PSK is the WIFI router WPA/WPA2 password used at the Wifi network connection.
 * Make sure to update the WLAN_PSK constant according to your router password.
 */
//#define WLAN_PASSWORD_DEFAULT                 "pacom123"
#define WLAN_PASSWORD_DEFAULT                 "80755631"
/**
 * WLAN_STATIC_IP is a boolean. If "true" then static IP will be assigned and if "false" then DHCP is used.
 */
#define WLAN_STATIC_IP_DEFAULT                      false

/**
 * WLAN_IP_ADDR is the WIFI router WPA/WPA2 static IPv4 IP address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_IP_ADDR constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_IP_ADDR_DEFAULT                        XDK_NETWORK_IPV4(0, 0, 0, 0)

/**
 * WLAN_GW_ADDR is the WIFI router WPA/WPA2 static IPv4 gateway address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_GW_ADDR constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_GW_ADDR_DEFAULT                        XDK_NETWORK_IPV4(0, 0, 0, 0)

/**
 * WLAN_DNS_ADDR is the WIFI router WPA/WPA2 static IPv4 DNS address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_DNS_ADDR constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_DNS_ADDR_DEFAULT                       XDK_NETWORK_IPV4(0, 0, 0, 0)

/**
 * WLAN_MASK is the WIFI router WPA/WPA2 static IPv4 mask address (unused if WLAN_STATIC_IP is false)
 * Make sure to update the WLAN_MASK constant according to your required WIFI network,
 * if WLAN_STATIC_IP is "true".
 */
#define WLAN_MASK_DEFAULT                           XDK_NETWORK_IPV4(0, 0, 0, 0)

/* UDP server configurations ************************************************ */

/**
 * DEST_SERVER_IP is the destination server IP address of the web server we will send UDP payloads.
 * If you want to test this example without setting up your own server, you can use publicly available services.
 */
//#define DEST_SERVER_IP                      XDK_NETWORK_IPV4(192, 168, 1, 88)
#define DEST_SERVER_IP                      XDK_NETWORK_IPV4(10, 42, 0, 1)

/**
 * DEST_SERVER_PORT is the UDP port to which we will send UDP payloads.
 */
//#define DEST_SERVER_PORT                    UINT16_C(5511)
#define DEST_SERVER_PORT                    UINT16_C(9090)

/**
 * APP_CONTROLLER_TX_DELAY is the packet transmit frequency in milli second over UDP & BLE.
 */
#define APP_CONTROLLER_TX_DELAY             UINT32_C(1000)

#define APP_ATTRIB_REPT_DELAY               UINT32_C(20) //in sensor report

#define APP_LED_INDICATE_ONLINE             LED_INBUILT_YELLOW

/**
 * APP_CONTROLLER_BLE_DEVICE_NAME is the BLE device name.
 */
#define APP_CONTROLLER_BLE_DEVICE_NAME     "XDK-AABBCCDDEEFF"

/**
 * APP_CONTROLLER_BLE_START_ID is the part of the payload to be received from
 * BLE central to start streaming data via. BLE.
 */
#define APP_CONTROLLER_BLE_START_ID         "start"

/**
 * APP_CONTROLLER_BLE_END_ID is the part of the payload to be received from
 * BLE central to stop streaming data via. BLE.
 */
#define APP_CONTROLLER_BLE_END_ID           "end"

/**
 * APP_CONTROLLER_BLE_START_PAYLOAD is the first payload to be sent to the
 * BLE central upon successful reception of APP_CONTROLLER_BLE_START_ID.
 * Must not be more than 20 bytes.
 */
#define APP_CONTROLLER_BLE_START_PAYLOAD    "X      Y      Z"

/**
 * APP_CONTROLLER_BLE_END_PAYLOAD is the last payload to be sent to the
 * BLE central upon successful reception of APP_CONTROLLER_BLE_END_ID.
 * Must not be more than 20 bytes.
 */
#define APP_CONTROLLER_BLE_END_PAYLOAD      "Transfer Terminated!"

/* local function prototype declarations */
#define LWM2M_DEF_SERVER_DEFAULT                 "coap://leshan.eclipse.org:5683" /**< using standard CoAP ports unsecure 5683 secure 5684, giving an appending port will override */

/* LWM2M_DTLS_PSK_IDENTITY_DEFAULT, if empty LWM2M_ENDPOINT_NAME_DEFAULT is used */
#define LWM2M_ENDPOINT_NAME_DEFAULT             "lwm2m.xdk:#---MAC----#"         /**< Macro to represent the lwm2m endpoint name. Magic #*# is replaced by MAC */

//#warning Please enter DTLS/PSK identity and secret key, if encrypted communication is wanted and remove this line.
#define LWM2M_DTLS_PSK_IDENTITY_DEFAULT          ""            /**< DTLS/PSK default identity */
#define LWM2M_DTLS_PSK_SECRET_KEY_HEX_DEFAULT    ""            /**< DTLS/PSK default secret key hexadecimal*/
#define LWM2M_DTLS_PSK_SECRET_KEY_DEFAULT        ""

#define LWM2M_BINDING_DEFAULT                   "U"
#define LWM2M_CON_NOTIFIES_DEFAULT              false
#define LWM2M_LIFETIME_DEFAULT                  "240"                            /**< Macro to represent the default lifetime in s. */
#define LWM2M_TEST_MODE_DEFAULT                 "MIX"


/**
 * HTTP_DEST_SERVER_HOST is the host name of the web server we will send HTTP requests to.
 * If you want to test this example without setting up your own server, you can use publicly available services.
 */
#define HTTP_DEST_SERVER_HOST                "api-iot.pacom.cn"

/**
 * HTTP_DEST_SERVER_PORT is the TCP port to which we will send HTTP requests to.
 * The default of 80 should be fine for most applications.
 */
#define HTTP_DEST_SERVER_PORT                UINT16_C(80)

/**
 * HTTP_DEST_SERVER_PORT_SECURE is the TCP port to which we will send HTTPS requests to.
 * The default of 443 should be fine for most applications.
 */
#define HTTP_DEST_SERVER_PORT_SECURE         UINT16_C(443)

/**
 * HTTP_DEST_GET_PATH is the path relative to the HTTP_DEST_SERVER_HOST that we will send
 * the HTTP GET request to. Using / will retrieve the index page of the web server
 * which for demo purposes may be enough.
 *
 * Change this value if you use your own web server.
 */
#define HTTP_DEST_GET_PATH                   "/api/gateway/search?deviceId="

/**
 * HTTP_DEST_POST_PATH is the path relative to the HTTP_DEST_SERVER_HOST that we will send
 * the HTTP POST request to.
 *
 * Change this value if you use your own web server.
 */
#define HTTP_DEST_POST_PATH                  "/post"

/**
 * POST_REQUEST_CUSTOM_HEADER_0 is a custom header which is sent along with the
 * POST request. It's meant to demonstrate how to use custom header.
 */

#define POST_REQUEST_CUSTOM_HEADER_0    "X-AuthToken: InsertCrypticAuthenticationToken\r\n"

/**
 * POST_REQUEST_CUSTOM_HEADER_1 is a custom header which is sent along with the
 * POST request. It's meant to demonstrate how to use custom header.
 */
#define POST_REQUEST_CUSTOM_HEADER_1    "X-Foobar: AnotherCustomHeader\r\n"

/**
 * POST_REQUEST_BODY is sent as body with the HTTP POST request
 */
#define POST_REQUEST_BODY               "{ \"device\": \"XDK110\", \"ping\": \"pong\" }"

/**
 * The time we wait (in milliseconds) between sending HTTP requests.
 */
#define INTER_REQUEST_INTERVAL          UINT32_C(10000)

#warning Configure HTTP_SECURE_ENABLE to 1 to enable the HTTPS based Communication otherwise Communication will happen through HTTP.

/**
 * HTTP_SECURE_ENABLE is Set to Use HTTP With Security
 */
#define HTTP_SECURE_ENABLE              UINT32_C(0)

#if HTTP_SECURE_ENABLE /* Below are SNTP related macros which are only valid for HTTPS */

/**
 * SNTP_SERVER_URL is the SNTP server URL.
 */
#define SNTP_SERVER_URL                 "0.de.pool.ntp.org"

/**
 * SNTP_SERVER_PORT is the SNTP server port number
 */
#define SNTP_SERVER_PORT                UINT16_C(123)

#endif /* #if HTTP_SECURE_ENABLE */

/**
 * The maximum amount of data we download in a single request (in bytes). This number is
 * limited by the platform abstraction layer implementation that ships with the
 * XDK. The maximum value that will work here is 512 bytes.
 */
#define REQUEST_MAX_DOWNLOAD_SIZE       UINT32_C(512)



#if HTTP_SECURE_ENABLE
#define APP_RESPONSE_FROM_SNTP_SERVER_TIMEOUT           UINT32_C(10000)/**< Timeout for SNTP server time sync */
#endif /* HTTP_SECURE_ENABLE */

#define APP_RESPONSE_FROM_HTTP_SERVER_POST_TIMEOUT      UINT32_C(25000)/**< Timeout for completion of HTTP rest client POST */

#define APP_RESPONSE_FROM_HTTP_SERVER_GET_TIMEOUT       UINT32_C(25000)/**< Timeout for completion of HTTP rest client GET */

#define APP_QUERY_UPSTREAM_CONFIG_TIMEOUT               UINT32_C(3*60*1000)

/**
 * @brief Gives control to the Application controller.
 *
 * @param[in] cmdProcessorHandle
 * Handle of the main command processor which shall be used based on the application needs
 *
 * @param[in] param2
 * Unused
 */
void AppController_Init(void * cmdProcessorHandle, uint32_t param2);

#endif /* APPCONTROLLER_H_ */

/** ************************************************************************* */
